package com.cy.pj.goods.controller;

import com.cy.pj.goods.pojo.Goods;
import com.cy.pj.goods.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class GoodsController {
    @Autowired
    private GoodsService goodsService;

    @RequestMapping("/goods/doSaveGoods")
    public String doSaveGoods(Goods entity) {
        goodsService.saveGoods(entity);
        return "save ok";
    }

    @RequestMapping("/goods/doDeleteById/{id}")
    public String doDeleteById(@PathVariable("id") Integer id){
        goodsService.deleteById(id);
        return "delete ok";
    }

    /**查询所有商品信息*/
    @GetMapping("/goods/doFindGoods")
    public List<Goods> doFindGoods(){
        return  goodsService.findGoods();
    }
}